/**
 * 
 */
package blms.system.league;

import java.util.Date;
import java.util.HashMap;

import blms.system.exception.restrictions.RestrictionException;
import blms.system.user.User;
import blms.system.util.BLMSMessages;
import blms.system.util.Validator;


/**
 * @author thiago
 *
 */
public class League {

	private final String id;
	private String name;
	private User operator;
	private Date creationDate;
	
	private HashMap<String,User> users;
	
	/**
	 * @param leagueID
	 * @param name
	 * @param operator
	 * @param creationDate
	 * @throws RestrictionException 
	 */
	public League(String leagueID, String name, User operator, Date creationDate) throws RestrictionException {
		
		if(Validator.isBlankOrNull(name)) {
			throw new RestrictionException(BLMSMessages.REQUIRED_DATA_MESSAGE+"league name");
		}
		
		this.id = leagueID;
		this.name = name;
		this.operator = operator;
		this.creationDate = creationDate;

		this.users = new HashMap<String,User>();
		this.users.put(operator.getID(), operator);
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the operator
	 */
	public User getOperator() {
		return operator;
	}

	/**
	 * @return the date
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @param name the name to set
	 * @throws RestrictionException 
	 */
	public void setName(String name) throws RestrictionException {
		this.name = name;
	}

	/**
	 * @param operator the operator to set
	 */
	public void setOperator(User operator) {
		this.operator = operator;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return this.getName();
	}

}
